part of 'page.dart';

class _SingleLexicalItemPageView extends StatelessWidget {
  const _SingleLexicalItemPageView({
    required _SingleLexicalItemPageWloc wloc,
  }) : _wloc = wloc;

  final _SingleLexicalItemPageWloc _wloc;

  Widget _buildContent({
    required _SingleLexicalItemPageWlocState state,
    required BuildContext context,
  }) {
    return CardFullContent(
      dialect: state.dialect,
      lexicalItem: state.lexicalItem,
      safeToPronounce: state.safeToPronounce,
      imagePath: state.imagePath,
      onLexicalItemPronunciationButtonPressed: _wloc.onPronunciationButtonPressed,
      onUseCasePronunciationButtonPressed: _wloc.onUseCasePronunciationButtonPressed,
      onMoreActionButtonPressed: _wloc.showCardActions,
      onPronunciationCautionButtonPressed: _wloc.onPronunciationCautionButtonPressed,
    );
  }

  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      resizeToAvoidBottomInset: false,
      backgroundColor: CoreTheme.of(context).backgroundColor,
      navigationBar: CupertinoNavigationBar(
        backgroundColor: CoreTheme.of(context).navigationBarColor,
        brightness: CoreTheme.of(context).brightness,
        automaticallyImplyLeading: false,
        automaticallyImplyMiddle: false,
        padding: EdgeInsetsDirectional.zero,
        middle: NavigationBarTitle(
          title: SingleLexicalItemPageTranslation.of(context).title,
        ),
        leading: AppBackButton(
          onPressed: Navigator.of(context).pop,
        ),
      ),
      child: LexicalItemCard(
        child: WlocBuilder<_SingleLexicalItemPageWloc, _SingleLexicalItemPageWlocState>(
          wloc: _wloc,
          builder: (context, state) {
            return _buildContent(
              state: state,
              context: context,
            );
          },
        ),
      ),
    );
  }
}
